<?php

/**
 * User form base class.
 *
 * @method User getObject() Returns the current form's model object
 *
 * @package    rpgcom
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseUserForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'idUser'   => new sfWidgetFormInputHidden(),
      'Name'     => new sfWidgetFormInputText(),
      'UserName' => new sfWidgetFormInputText(),
      'Password' => new sfWidgetFormInputText(),
      'Email'    => new sfWidgetFormInputText(),
      'Admin'    => new sfWidgetFormInputText(),
      'RegDate'  => new sfWidgetFormDate(),
    ));

    $this->setValidators(array(
      'idUser'   => new sfValidatorPropelChoice(array('model' => 'User', 'column' => 'idUser', 'required' => false)),
      'Name'     => new sfValidatorString(array('max_length' => 30)),
      'UserName' => new sfValidatorString(array('max_length' => 30)),
      'Password' => new sfValidatorString(array('max_length' => 100)),
      'Email'    => new sfValidatorString(array('max_length' => 60)),
      'Admin'    => new sfValidatorInteger(array('min' => -128, 'max' => 127)),
      'RegDate'  => new sfValidatorDate(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'User', 'column' => array('Email'))),
        new sfValidatorPropelUnique(array('model' => 'User', 'column' => array('UserName'))),
      ))
    );

    $this->widgetSchema->setNameFormat('user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'User';
  }


}
